package chap11;

import java.io.*;
import java.util.Scanner;

public class Classex1 {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);

        System.out.println("请输入一个整数：");
        int a = scan.nextInt();

        int b = Classex1.calculate(a);
        System.out.println("F(n)的值为：" + b);

        FileWriter F = new FileWriter("C:\\Users\\恺\\IdeaProjects\\GK20172301_JavaProgramming\\classex.txt");
        F.write("F(n)的值为：" + b);
        F.flush();
    }

    public static int calculate(int num){
        int result = 0;
        if (num == 0 || num == 1)
        {
            result = num;
        }
        else
        {
            result = calculate(num - 1) + calculate(num - 2);
        }
        return result;
        }
}
